package com.carrental.crm.client;

import com.carrental.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 租赁服务客户端
 * 用于远程调用car-rental服务
 */
@FeignClient(name = "car-rental")
public interface RentalClient {

    /**
     * 创建订单
     *
     * @param orderDTO 订单DTO
     * @return 订单ID
     */
    @PostMapping("/orders")
    Result<Long> createOrder(@RequestBody Object orderDTO);

    /**
     * 根据用户ID分页查询订单
     *
     * @param current   当前页码
     * @param size      每页数量
     * @param userId    用户ID
     * @param status    订单状态
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @return 订单分页数据
     */
    @GetMapping("/orders/user")
    Result<Map<String, Object>> pageUserOrders(@RequestParam(defaultValue = "1") long current,
            @RequestParam(defaultValue = "10") long size,
            @RequestParam Long userId,
            @RequestParam(required = false) Integer status,
            @RequestParam(required = false) String startTime,
            @RequestParam(required = false) String endTime);

    /**
     * 根据订单号获取订单详情
     *
     * @param orderNo 订单号
     * @return 订单详情
     */
    @GetMapping("/orders/no/{orderNo}")
    Result<Object> getOrderByOrderNo(@PathVariable String orderNo);

    /**
     * 支付订单
     *
     * @param id 订单ID
     * @return 是否成功
     */
    @PutMapping("/orders/{id}/pay")
    Result<Boolean> payOrder(@PathVariable Long id);

    /**
     * 取消订单
     *
     * @param id 订单ID
     * @return 是否成功
     */
    @PutMapping("/orders/{id}/cancel")
    Result<Boolean> cancelOrder(@PathVariable Long id);
}